
let timeout //防抖，  
// 防抖
function debounce(time) {
	return new Promise((resolve) => {
		if (timeout) {
			clearTimeout(timeout)
		}
		timeout = setTimeout(() => {
			resolve()
		}, time)
	})
};
// 节流
var canRun = true;

function throttle(time) {
	return new Promise((resolve) => {
		if (canRun == true) {
			clearTimeout(timerun)
			canRun = false
			var timerun = setTimeout(() => {
				canRun = true;
			}, time);
			resolve()
		}
	})
}



module.exports = {
	debounce, //防抖
	throttle, // 节流
}
